<script type="text/javascript">
	function doSearchMatchProject(value) {
		
	}
	
	//表格查询  
	function reloadMatchProject() {
		var params = matchProject_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		matchProject_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		matchProject_list.datagrid('unselectAll');
		matchProject_list.datagrid('uncheckAll');
	}


	function addMatchProject() {
		createFromWindow("新增信息", "matchProject.do?editMatchProject", "matchProject.do?saveMatchProject",
				function(data) {
					reloadMatchProject();
				});
	}
	
	function deleteMatchProject() {
		var rows = matchProject_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('matchProject.do?deleteMatchProjectItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadMatchProject();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}

	function editMatchProject() {
		var rows = matchProject_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow("编辑信息", "matchProject.do?editMatchProject&matchProjectId=" + rows[0].id,
					"matchProject.do?saveMatchProject", function(data) {
						reloadMatchProject();
					},true);
		} else {
			showMsg('请选择操作记录.');
		}

	}
	
	
	function clearMatchProjectSearch() {
		setGridSearchParams('matchProject_list','matchProjectSearchForm',true,reloadMatchProject);
	}
	
	//根据条件查询
	function matchProjectSearch() {
		setGridSearchParams('matchProject_list','matchProjectSearchForm',false,reloadMatchProject);
	}
	
	function onDblClickMatchProjectRow(rowIndex, rowData) {
		createFromWindow("编辑信息", "matchProject.do?editMatchProject&matchProjectId=" + rowData.id,
					"matchProject.do?saveMatchProject", function(data) {
						reloadMatchProject();
					},true);
	}
	
	
	function publishMatchProject() {
		var rows = matchProject_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要发布吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('matchProject.do?publishMatchProjectItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadMatchProject();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择赛事活动！");
	    }
	}
	
	function revokeMatchProject() {
		var rows = matchProject_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要撤销吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('matchProject.do?revokeMatchProjectItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadMatchProject();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}
	
	function operationsEditMatchroject(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = matchProject_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("编辑信息", "matchProject.do?editMatchProject&matchProjectId=" + id,
					"matchProject.do?saveMatchProject", function(data) {
						reloadMatchProject();
					},true);
		} else {
			showMsg('请选择编辑记录.');
		}
	}
	
	function operationsLookMatchroject(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = matchProject_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
//             $.post('matchProject.do?allowLookMatchProject',{id:id},function(result){
//             	if (result.success){
                	window.open('cms.action?skip&navCode=sshd&look=1');
//                 } else {
//                 	showMsg(result.msg);
//                 }
//             },'json');
		} else {
			showMsg('请选择需要结束的记录.');
		}
		
	}
	
	function operationsEndMatchProject(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = matchProject_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			$.messager.confirm('询问','你确认要结束吗?',function(r){
	            if (r){
	            	var ids = ""+id;
	                $.post('matchProject.do?endMatchProject',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadMatchProject();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
		} else {
			showMsg('请选择需要结束的记录.');
		}
	}
	
	function operationsManagerMatchProject(id) {
		printLog('管理'+id);
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = matchProject_list.datagrid('getSelections');
			id = rows[0].id;
		}
		printLog(id);
		if (id) {
			//记得先自动选中
			matchProject_list.datagrid('selectRecord',id);
			var record = matchProject_list.datagrid('getSelected');
			printLog(record);
			//关闭左侧菜单树
			$('#mainLayout').layout('collapse','west');
			//避免同时打开多个赛事管理tab，先关闭
			window.mainpage.mainTabs.closeTab('赛事信息');
			window.mainpage.clickMenuAddModelTab(111111,'赛事信息','','matchProject.do?manager&matchId='+id,'icon-standard-application-form',false);
		} else {
			showMsg('请选择记录.');
		}
	}
	
	function operationsLookPsUrl(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = matchProject_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			openwin('matchLogin.action?sysLogin&sshdId='+id);
		} else {
			showMsg('请选择需要评审的记录.');
		}
	}
	
	function openwin(url) {
		var a = document.createElement("a");
		a.setAttribute("href", url);
		a.setAttribute("target", "_blank");
		a.setAttribute("id", "camnpr");
		document.body.appendChild(a);
		a.click();
	}
</script>

<#assign operations = "[\{shiro:'match:matchProject:manager',onClick:'operationsManagerMatchProject',title:'管理'},
	   					\{shiro:'match:matchProject:edit',onClick:'operationsEditMatchroject',title:'编辑'},
	   					\{shiro:'match:matchProject:look',onClick:'operationsLookMatchroject',title:'预览'},
	   					\{shiro:'match:matchProject:end',onClick:'operationsEndMatchProject',title:'结束'},
	   					\{shiro:'match:matchProject:lookPsUrl',onClick:'operationsLookPsUrl',title:'评审地址'}
	  				   ]"/>
<div class="easyui-layout" data-options="fit:true">
	<div data-options="region:'center',border:false">
		<@eu.datagrid id="matchProject_list" toolbar="#matchProjectlist_search" idField="id"  url="matchProject.do?loadList" rownumbers="true" onDblClickRow="onDblClickMatchProjectRow(rowIndex, rowData)"
			 item="com.xdtech.match.vo.MatchProjectItem" operations="${operations!}"/>
		
		<div id="matchProjectlist_search">
			<div style="margin-bottom:5px;padding-left:5px;margin-top: 5px;">
				<form id="matchProjectSearchForm">
					<!-- 防止form表单里只有一个text元素时候，按enter键自动提交问题 -->
					<input style="display:none" />
					<table>
						<tr>
							<td>比赛名称：</td>
							<td><input class="easyui-validatebox textbox" name="matName" style="width: 150px"/></td>
<!-- 							<td>开始时间：</td> -->
<!-- 							<td><input name="beginDay"  class="easyui-datebox" style="width: 158px"/></td> -->
<!-- 							<td>结束时间：</td> -->
<!-- 							<td><input name="endDay"  class="easyui-datebox" style="width: 158px"/></td> -->
							<td>大赛状态：</td>
							<td><@eu.comboBox name="matStatu" url="common.do?loadComboBox&key=MATCH_STATU" /></td>
							<td>发布状态：</td>
							<td><@eu.comboBox name="publishStatu" url="common.do?loadComboBox&key=MATCH_PUBLISH_STATU" /></td>
							<td>年份：</td>
							<td>
<!-- 								<input name="yearDate"  class="easyui-datebox" style="width: 158px"/> -->
								<select class="easyui-combobox" name="yearDate" style="width:158px;">
								    <option value="2017">2017</option>
								    <option value="2018">2018</option>
								    <option value="2019">2019</option>
								    <option value="2020">2020</option>
								    <option value="2021">2021</option>
								    <option value="2022">2022</option>
								    <option value="2023">2023</option>
								</select>
							</td>
							
							<td>
								<@eu.linkbutton showName="查询" iconCls="icon-search" onclick="matchProjectSearch()"/>
	 					 		<@eu.linkbutton showName="清空" iconCls="icon-clear" onclick="clearMatchProjectSearch()"/>
 					 		</td>
						</tr>
					</table>
				</form>
				
			</div>
			<div id="matchProject_toolbar" style="height: auto">
				<@eu.linkbutton showName="新增" shiro="match:matchProject:add" iconCls="icon-add" onclick="addMatchProject()"/>
<!-- 				<@eu.linkbutton showName="删除" shiro="match:matchProject:delete" iconCls="icon-remove" onclick="deleteMatchProject()"/> -->
				<@eu.linkbutton showName="编辑" shiro="match:matchProject:edit" iconCls="icon-edit" onclick="editMatchProject()"/>
				<@eu.linkbutton showName="发布" shiro="match:matchProject:publish" iconCls="icon-remove" onclick="publishMatchProject()"/>
				<@eu.linkbutton showName="撤销" shiro="match:matchProject:revoke" iconCls="icon-remove" onclick="revokeMatchProject()"/>
<!-- 				<@eu.linkbutton showName="查看评审路径" shiro="match:matchProject:lookPsUrl" iconCls="icon-reload" onclick="lookMatchProjectPsUrl()"/> -->
				<@eu.linkbutton showName="刷新" shiro="match:matchProject:refresh" iconCls="icon-reload" onclick="reloadMatchProject()"/>
			</div>
		</div>
	</div>
</div>